<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" th:with="title='成功案例列表',active='project'">
<header th:replace="admin/header::headerFragment(${title},${active})"></header>
<body class="fixed-left">
<div id="wrapper">
    <div th:replace="admin/header::header-body"></div>
    <div class="content-page">
        <div class="content">
            <div class="container">
                <div class="row">
                    <div class="col-sm-12">
                        <h4 class="page-title">成功案例列表</h4>
                    </div>
                    <div class="col-md-12">

                        <form action="/admin/project/search">
                            <div class="form-group col-md-3" style="padding: 0 10px 0 0;">
                                <select id="subtype" name="subtype" class="form-control">
                                    <option value="">- 请选择类型 -</option>
                                    <option value="LONGHUA">龙华区补贴项目</option>
                                    <option value="BAOAN">宝安区补贴项目</option>
                                    <option value="NANSHAN">南山区补贴项目</option>
                                    <option value="FUTIAN">福田区补贴项目</option>
                                    <option value="LUOHU">罗湖区补贴项目</option>
                                    <option value="LONGGANG">龙岗区补贴项目</option>
                                    <option value="GUANGMING">光明新区补贴项目</option>
                                </select>
                            </div>
                            <div class="form-group col-md-2">
                                <button type="submit" class="btn btn-success waves-effect waves-light m-b-5"><i class="fa fa-search"></i>查询</button>
                            </div>
                        </form>

                        <div class="pull-right">
                            <a th:href="@{/admin/project/add}" class="btn btn-success waves-effect waves-light m-b-5">
                                <i class="fa fa-edit"></i>
                                <span>新增</span>
                            </a>
                        </div>
                        <table class="table table-striped table-bordered">
                            <thead>
                            <tr>
                                <th width="20%">图片</th>
                                <th>标题</th>
                                <th width="20%">描述</th>
                                <th width="10%">类型</th>
                                <th width="20%">创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <th:block th:each="row : ${projects.list}">
                                <tr th:id="${row.id}">
                                    <td style="text-align: center">
                                        <div style="display: inline-block; position: relative; width:200px; height:100px;overflow: hidden;">
                                            <img style="position: absolute; margin: auto; top: 0px; right: 0px; bottom: 0px; left: 0px; max-width:100%; max-height:100%" th:src="${row.img}"  alt="图片">
                                        </div>
                                    </td>
                                    <td th:text="${row.title}"></td>
                                    <td th:text="${row.summary}"></td>
                                    <td>
                                        <th:block th:if="${row.subtype == 'LONGHUA'}" th:text="龙华区补贴项目"/>
                                        <th:block th:if="${row.subtype == 'BAOAN'}" th:text="宝安区补贴项目"/>
                                        <th:block th:if="${row.subtype == 'NANSHAN'}" th:text="南山区补贴项目"/>
                                        <th:block th:if="${row.subtype == 'FUTIAN'}" th:text="福田区补贴项目"/>
                                        <th:block th:if="${row.subtype == 'LUOHU'}" th:text="罗湖区补贴项目"/>
                                        <th:block th:if="${row.subtype == 'LONGGANG'}" th:text="龙岗区补贴项目"/>
                                        <th:block th:if="${row.subtype == 'GUANGMING'}" th:text="光明新区补贴项目"/>
                                    </td>
                                    <td th:text="${row.createTime} ? ${#dates.format(row.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                                    <td>
                                        <a th:href="@{'/admin/project/edit/'+${row.id}}" class="btn btn-primary btn-sm waves-effect waves-light m-b-5">
                                            <i class="fa fa-edit"></i> <span>编辑</span>
                                        </a>
                                        <a href="javascript:void(0)" th:onclick="'del('+${row.id}+');'" class="btn btn-danger btn-sm waves-effect waves-light m-b-5">
                                            <i class="fa fa-trash-o"></i> <span>删除</span>
                                        </a>
                                        <!--
                                        <a class="btn btn-warning btn-sm waves-effect waves-light m-b-5"
                                           th:href="@{'/'+${row.id}}" target="_blank">
                                            <i class="fa fa-rocket"></i> <span>预览</span></a>
                                         -->
                                    </td>
                                </tr>
                            </th:block>
                            </tbody>
                        </table>
                        <div th:replace="comm/paginator :: pageAdminNav(${projects}, '/admin/project/list')"></div>
                    </div>
                </div>
                <div th:replace="admin/footer :: footer-content"></div>
            </div>
        </div>
    </div>
</div>
<div th:replace="admin/footer :: footer"></div>
<script type="text/javascript">
    /*<![CDATA[*/
    var tale = new $.tale();

    function del(id) {
        tale.alertConfirm({
            title: '确定删除选中的成功案例吗?',
            // showCancelButton : true,
            // type : 'question',
            then: function () {
                $.ajax({
                    url: '/admin/project/del/' + id,
                    dataType: 'json',
                    success: function (result) {
                        if (result && result.success) {
                            tale.alertOkAndReload('删除成功');
                        } else {
                            tale.alertError(result.msg || '删除失败');
                        }
                    }
                });
            }
        });
    }

    /*]]>*/
</script>
</body>
</html>